import ajax from '../utils/request.js'
// 获取文章频道
function channels (params) {
  return ajax({
    url: '/mp/v1_0/channels',
    params
  })
}
// 发表文章
function articles (data) {
  return ajax({
    url: `/mp/v1_0/articles?draft=${data.draft}`,
    method: 'post',
    data
  })
}

// 编辑文章
function compile (data, id) {
  console.log(data)
  return ajax({
    url: `/mp/v1_0/articles/${id}?draft=${data.status}`,
    method: 'PUT',
    data
  })
}

// 获取文章
function acquire (id) {
  return ajax({
    url: `/mp/v1_0/articles/${id}`
  })
}

function getImg (params) {
  return ajax({
    url: 'http://ttapi.research.itcast.cn/mp/v1_0/user/images',
    params
  })
}

export { channels, articles, compile, acquire, getImg }
